const items = [
    { category: 'fruit', name: 'Apple' },
    { category: 'vegetable', name: 'Carrot' },
    { category: 'fruit', name: 'Banana' },
    { category: 'vegetable', name: 'Broccoli' },
];
  
// 去重
const result = items.reduce((cur, item) => {
    let isOk = cur.some(i => i.category == item.category)
    if(isOk){
        return cur;
    }else {
        return [...cur, item]
    }
},[])

console.log(result);// [{ category: 'fruit', name: 'Apple' }, { category: 'vegetable', name: 'Carrot' }]